//
//  HarassmentInterception.m
//  timelyRain
//
//  Created by Jiafei Wei on 16/9/29.
//  Copyright © 2016年 Jiafei Wei. All rights reserved.
//

#import "HarassmentInterception.h"
#import "MyMark.h"
#import "CallVC.h"
#import "SmsVC.h"
#import "MBTPre.h"
#import "TagBlackNumber.h"
@interface HarassmentInterception (){
    NSMutableArray *callIntercept;
    NSMutableArray *smsIntercept;
}
@property (weak, nonatomic) IBOutlet UISegmentedControl *seg;
- (IBAction)choose:(id)sender;
@property (weak, nonatomic) IBOutlet UIScrollView *content;

@end

@implementation HarassmentInterception

- (void)viewDidLoad {
    [super viewDidLoad];
    [super setTitleView:self.view withName:@"骚扰拦截" with:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (IBAction)choose:(id)sender {
    UISegmentedControl* control = (UISegmentedControl*)sender;
    switch (control.selectedSegmentIndex) {
        case 0:
            NSLog(@"UISegmentedControl===0");//切换view
            CGFloat X = 0 * self.view.frame.size.width;
            CGFloat Y = _content.bounds.origin.y;
            [_content setContentOffset:CGPointMake(X, Y) animated:YES];
            break;
        case 1:
            NSLog(@"UISegmentedControl===1");//却换对象
            CGFloat X1 = 1 * self.view.frame.size.width;
            CGFloat Y1 = _content.bounds.origin.y;
            [_content setContentOffset:CGPointMake(X1, Y1) animated:YES];
            break;
    }
}

-(void)viewWillLayoutSubviews{
    [super viewWillLayoutSubviews];
    [self setupViewControllers];
}
- (void)setupViewControllers
{
    CGRect rr =_content.bounds;
    CallVC  *call = [[CallVC alloc]initWithNibName:@"CallVC" bundle:nil];
    [self addChildViewController:call];
    call.view.frame = CGRectMake(0, rr.origin.y, rr.size.width, rr.size.height);
    [_content addSubview:call.view];
    
    SmsVC *sms = [[SmsVC alloc]initWithNibName:@"SmsVC" bundle:nil];
    [self addChildViewController:sms];
    sms.view.frame = CGRectMake(SCREEN_W,rr.origin.y, rr.size.width, rr.size.height);
    [_content addSubview:sms.view];
    //[_content setContentSize:CGSizeMake(rr.size.width *3,0)];
    _content.pagingEnabled = NO;
    //_content.delegate = self;
}
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:YES];
}
-(void)keep{
    TagBlackNumber *black =[[TagBlackNumber alloc]init];
    [self.navigationController pushViewController:black animated:YES];
}
@end
